/*
* @Author: Administrator
* @Date:   2017-12-13 15:02:25
* @Last Modified by:   Administrator
* @Last Modified time: 2018-01-09 15:58:13
*/
const path = require('path')
const express = require('express')
const favicon = require('serve-favicon')

const bodyParser = require('body-parser')
const session = require('express-session')

const app = express()
const isDev = process.env.NODE_ENV === 'dev'
const handleApi = require('./util/hanleApiRequest.js')
const serverDev = require('./util/dev.js')
const serverDist = require('./util/dist.js')

app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false }))
app.use(session({
  maxAge: 10 * 60 * 1000,
  name: 'tid',
  resave: false,
  saveUninitialized: false,
  secret: 'I will teach you'
}))
app.use(favicon(path.join(__dirname, '../favicon.ico')))
handleApi(app)
if (isDev) {
  serverDev(app)
} else {
  serverDist(app)
}
app.listen(3334, function () {
  console.log('启动成功')
})
